﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="insertTeacherData.aspx.cs" Inherits="Staff_insertTeacherData" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>新增編輯教師資料</title>
    <style type="text/css">


        .style1
        {
            font-family: 微軟正黑體;
            font-size: xx-large;
            text-align: center;
        }
        .style2
        {
            text-align: center;
        }
        .style3
        {
            width: 79%;
        }
        </style>
</head>
<body>
    <form id="form1" runat="server">
    <div class="style2">
    
        <span class="style1">新增編輯教師資料</span><br />
        <br />
        <table align="center" class="style3">
            <tr>
                <td>
                    <br />
                    <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" BackColor="#F7F6F3" 
                        BorderColor="#E6E2D8" BorderStyle="Solid" BorderWidth="1px" 
                        Font-Names="Verdana" Font-Size="0.8em" Height="646px" 
                        oncreateduser="CreateUserWizard1_CreatedUser1" style="font-size: small" 
                        Width="433px" LoginCreatedUser="False">
                        <ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
                            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
                            ForeColor="#284775" />
                        <CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
                            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
                            ForeColor="#284775" />
                        <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <WizardSteps>
                            <asp:CreateUserWizardStep runat="server">
                                <ContentTemplate>
                                    <table style="font-family:Verdana;font-size:100%;height:646px;width:433px;">
                                        <tr>
                                            <td align="center" colspan="2" 
                                                style="color:White;background-color:#5D7B9D;font-weight:bold;">
                                                註冊您的新帳戶</td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">教師編號:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="UserName" runat="server"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
                                                    ControlToValidate="UserName" ErrorMessage="必須提供使用者名稱。" ToolTip="必須提供使用者名稱。" 
                                                    ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">密碼:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" 
                                                    ControlToValidate="Password" ErrorMessage="必須提供密碼。" ToolTip="必須提供密碼。" 
                                                    ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="ConfirmPasswordLabel" runat="server" 
                                                    AssociatedControlID="ConfirmPassword">確認密碼:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" 
                                                    ControlToValidate="ConfirmPassword" ErrorMessage="必須提供確認密碼。" 
                                                    ToolTip="必須提供確認密碼。" ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">電子郵件:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="Email" runat="server"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="EmailRequired" runat="server" 
                                                    ControlToValidate="Email" ErrorMessage="必須提供電子郵件。" ToolTip="必須提供電子郵件。" 
                                                    ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question">安全性問題:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="Question" runat="server"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="QuestionRequired" runat="server" 
                                                    ControlToValidate="Question" ErrorMessage="必須提供安全性問題。" ToolTip="必須提供安全性問題。" 
                                                    ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                <asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer">安全性解答:</asp:Label>
                                            </td>
                                            <td>
                                                <asp:TextBox ID="Answer" runat="server"></asp:TextBox>
                                                <asp:RequiredFieldValidator ID="AnswerRequired" runat="server" 
                                                    ControlToValidate="Answer" ErrorMessage="必須提供安全性解答。" ToolTip="必須提供安全性解答。" 
                                                    ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                教師姓名：</td>
                                            <td>
                                                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                實驗室：</td>
                                            <td>
                                                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                學位：</td>
                                            <td>
                                                <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                電話號碼：</td>
                                            <td>
                                                <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="right">
                                                手機號碼：</td>
                                            <td>
                                                <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="2">
                                                <asp:CompareValidator ID="PasswordCompare" runat="server" 
                                                    ControlToCompare="Password" ControlToValidate="ConfirmPassword" 
                                                    Display="Dynamic" ErrorMessage="密碼和確認密碼必須相符。" 
                                                    ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="center" colspan="2" style="color:Red;">
                                                <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                                            </td>
                                        </tr>
                                    </table>
                                </ContentTemplate>
                            </asp:CreateUserWizardStep>
                            <asp:CompleteWizardStep runat="server" />
                        </WizardSteps>
                        <HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True" 
                            Font-Size="0.9em" ForeColor="White" HorizontalAlign="Center" />
                        <NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" 
                            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" 
                            ForeColor="#284775" />
                        <SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" />
                        <SideBarStyle BackColor="#5D7B9D" BorderWidth="0px" Font-Size="0.9em" 
                            VerticalAlign="Top" />
                        <StepStyle BorderWidth="0px" />
                    </asp:CreateUserWizard>
                    <br />
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
            </tr>
            <tr>
                <td>
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
                        DataKeyNames="TeacherId" DataSourceID="SqlDataSource1" BackColor="White" 
                        BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" 
                        GridLines="Horizontal" Width="408px">
                        <AlternatingRowStyle BackColor="#F7F7F7" />
                        <Columns>
                            <asp:BoundField DataField="TeacherId" HeaderText="教師編號" 
                                InsertVisible="False" ReadOnly="True" SortExpression="TeacherId" />
                            <asp:BoundField DataField="TeacherName" HeaderText="姓名" 
                                SortExpression="TeacherName" />
                            <asp:BoundField DataField="Degree" HeaderText="學位" 
                                SortExpression="Degree" />
                            <asp:BoundField DataField="Email" HeaderText="電子郵件" SortExpression="Email" />
                            <asp:BoundField DataField="Lab" HeaderText="實驗室" SortExpression="Lab" />
                            <asp:CommandField ButtonType="Button" ShowEditButton="True" />
                        </Columns>
                        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
                        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
                        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
                        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
                        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
                        <SortedAscendingCellStyle BackColor="#F4F4FD" />
                        <SortedAscendingHeaderStyle BackColor="#5A4C9D" />
                        <SortedDescendingCellStyle BackColor="#D8D8F0" />
                        <SortedDescendingHeaderStyle BackColor="#3E3277" />
                    </asp:GridView>
                </td>
            </tr>
        </table>
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>" 
            DeleteCommand="DELETE FROM [Teacher] WHERE [TeacherId] = @TeacherId" 
            InsertCommand="INSERT INTO [Teacher] ([TeacherId], [TeacherName], [Email], [Lab], [Degree]) VALUES (@TeacherId, @TeacherName, @Email, @Lab, @Degree)" 
            SelectCommand="SELECT * FROM [Teacher]" 
            
            UpdateCommand="UPDATE [Teacher] SET [TeacherName] = @TeacherName, [Email] = @Email, [Lab] = @Lab, [Degree] = @Degree WHERE [TeacherId] = @TeacherId">
            <DeleteParameters>
                <asp:Parameter Name="TeacherId" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:SessionParameter Name="TeacherId" SessionField="id" Type="Int32" />
                <asp:SessionParameter Name="TeacherName" SessionField="name" Type="String" />
                <asp:SessionParameter Name="Email" SessionField="email" Type="String" />
                <asp:SessionParameter Name="Lab" SessionField="lab" Type="String" />
                <asp:SessionParameter Name="Degree" SessionField="degree" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="TeacherName" Type="String" />
                <asp:Parameter Name="Email" Type="String" />
                <asp:Parameter Name="Lab" Type="String" />
                <asp:Parameter Name="Degree" Type="String" />
                <asp:Parameter Name="TeacherId" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>" 
            DeleteCommand="DELETE FROM [TeacherPhone] WHERE [serial] = @serial" 
            InsertCommand="INSERT INTO [TeacherPhone] ([TeacherId], [Phone]) VALUES (@TeacherId, @Phone)" 
            SelectCommand="SELECT * FROM [TeacherPhone]" 
            
            UpdateCommand="UPDATE [TeacherPhone] SET [TeacherId] = @TeacherId, [Phone] = @Phone WHERE [serial] = @serial">
            <DeleteParameters>
                <asp:Parameter Name="serial" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:SessionParameter Name="TeacherId" SessionField="id" Type="Int32" />
                <asp:SessionParameter Name="Phone" SessionField="phone" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="TeacherId" Type="Int32" />
                <asp:Parameter Name="Phone" Type="String" />
                <asp:Parameter Name="serial" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ProjectConnectionString %>" 
            DeleteCommand="DELETE FROM [TeacherCellPhone] WHERE [serial] = @serial" 
            InsertCommand="INSERT INTO [TeacherCellPhone] ([TeacherId], [CellPhone]) VALUES (@TeacherId, @CellPhone)" 
            SelectCommand="SELECT * FROM [TeacherCellPhone]" 
            
            UpdateCommand="UPDATE [TeacherCellPhone] SET [TeacherId] = @TeacherId, [CellPhone] = @CellPhone WHERE [serial] = @serial">
            <DeleteParameters>
                <asp:Parameter Name="serial" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:SessionParameter Name="TeacherId" SessionField="id" Type="Int32" />
                <asp:SessionParameter Name="CellPhone" SessionField="cellphone" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="TeacherId" Type="Int32" />
                <asp:Parameter Name="CellPhone" Type="String" />
                <asp:Parameter Name="serial" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>
